<template>
  <el-container class="home-container">
    <!--页面头部-->
    <el-header>
      <div>
        <img src="../assets/img/logo.png" alt="logo" />
        <span>医院后台管理系统</span>
      </div>
      <el-button type="info" @click="logout">登出</el-button>
    </el-header>
    <!--页面主体-->
    <el-container>
      <!--侧边栏-->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <!--侧边栏菜单区域-->
        <el-menu
          background-color="#28333e"
          text-color="#fff"
          active-text-color="#409EFF"
          unique-opened
          :collapse="isCollapse"
          :collapse-transition="false"
        >
          <!--一级菜单-->
          <el-submenu index="1">
            <!--一级菜单模板区域-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-user"></i>
              <!--文本-->
              <span>门诊管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item-group>
              <!--文本-->
              <router-link to="/show">
                <el-menu-item index="1-1"> 挂号管理 </el-menu-item>
              </router-link>
              <router-link to="/charge">
                <el-menu-item index="1-2"> 收费管理 </el-menu-item>
              </router-link>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="2">
            <!--一级菜单-->
            <template slot="title">
              <i class="el-icon-location-outline"></i>
              <!--文本-->
              <span>住院管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item-group>
              <!--文本-->
              <router-link to="/hospital">
              <el-menu-item index="2-1">病人管理</el-menu-item>
              </router-link>
            </el-menu-item-group>
            <el-menu-item-group>
              <!--文本-->
              <router-link to="/bunk">
              <el-menu-item index="2-2">病床管理</el-menu-item>
              </router-link>
            </el-menu-item-group>
            <el-menu-item-group>
              <!--文本-->
              <el-menu-item index="2-3">预存管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <!--一级菜单-->
            <template slot="title">
              <i class="el-icon-school"></i>
              <span>药房管理</span>
            </template>

            <el-menu-item-group>
              <el-menu-item index="3-1">门诊发药</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group>
              <el-menu-item index="3-2">药房库存</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

             <el-submenu index="4">
            <!--一级菜单-->
            <template slot="title">
              <i class="el-icon-office-building"></i>
              <span>药库管理</span>
            </template>
            <el-menu-item-group>
              <router-link to="/storagedan">
              <el-menu-item index="4-1">药库库存</el-menu-item>
              </router-link>
            </el-menu-item-group>
          </el-submenu>




          <el-submenu index="5">
            <!--一级菜单-->
            <template slot="title">
              <i class="el-icon-s-platform"></i>
              <span>系统管理</span>
            </template>

            <el-menu-item-group>
              <el-menu-item index="5-1">人员管理</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group>
              <el-menu-item index="5-2">部门管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>

      <!--右侧内容主体-->
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false,
    };
  },
  methods: {
    // 这个是登出
    logout() {
      window.sessionStorage.clear();
      this.$router.push("login");
    },
    // 点击按钮切换菜单状态
    toggleCollapse() {
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style lang="less" scoped>
.el-header {
  background-color: #28333e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 10px;
    }
  }
}
 .click:focus {
  padding-left: 40px;
  color: rgb(64, 158, 255);
  background-color: rgb(40, 51, 62);
}
.el-aside {
  background-color: #28333e;
  .el-menu {
    border: none;
  }
}
.el-main {
  background-color: #f2f2f2;
}
.home-container {
  height: 100%;
}
.toggle-button {
  background-color: #28333e;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>